<template>
	<view class="tabbar-wrap">
		<view class="tab-list">
			<view class="item" @click.stop="switchTab(0)">
				<image class="icon" :fade-show='false' v-if="active==1" src="@/static/icon_home.png" mode="">
				</image>
				<image class="icon" :fade-show='false' v-if="active==0" src="@/static/icon_home_active.png"
					mode=""></image>
				<text :class="{'active' :active==0}">任务</text>
			</view>
			<view class="item" @click.stop="switchTab(1)">
				<image class="icon" :fade-show='false' v-if="active==0" src="@/static/icon_user.png" mode="">
				</image>
				<image class="icon" :fade-show='false' v-if="active==1" src="@/static/icon_user_active.png"
					mode=""></image>
				<text :class="{'active' :active==1}">我的</text>
			</view>
		</view>
		<view class="scan" @click.stop="goCreat">
			<image src="@/static/icon_creat.png" mode=""></image>
		</view>
	</view>
</template>

<script>
	import {
		mapMutations
	} from 'vuex'
	export default {
		data() {
			return {
				active: Number, // 当亲选择那个按钮
			}
		},
		inject: ['_mainFuncInit'], // 父级传递过来的函数
		methods: {
			getSetting(numbers) {
				this.active = numbers || 0
			},
			switchTab(index) {
				if (index === this.active) return
				console.log(index, this.active)
				this.SETSTATUSINDEX(index)
				this._mainFuncInit() // 回调父级函数
				this.active = index
			},
			goCreat() {
				uni.navigateTo({
					url: "/pages/waybill/creat"
				})
			},
			...mapMutations(['SETSTATUSINDEX'])
		}
	}
</script>

<style lang="scss" scoped>
	.tabbar-wrap {
		position: fixed;
		z-index: 1000;
		left: 0;
		bottom: 0;
		width: 100vw;
		height: calc(110rpx + env(safe-area-inset-bottom));
		box-shadow: 0 -1rpx 1rpx 0 rgba(0,0,0,0.08);
		flex: 1;
		background: #FFFFFF;
		.tabbar-bg {
			position: absolute;
			z-index: 11;
			width: 100vw;
			height: calc(110rpx);
		}

		.tab-list {
			position: absolute;
			z-index: 12;
			// margin-top: 4rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			width: 100vw;
			height: 100rpx;
		}

		.item {
			width: 42vw;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			font-size: 20rpx;

			.icon {
				width: 50rpx;
				height: 50rpx;
			}

			.active {
				color: #00468C;
			}
		}

		.scan {
			position: absolute;
			z-index: 20;
			top: 8rpx;
			left: 50%;
			width: 100rpx;
			height: 100rpx;
			transform: translate(-50%, 0);

			image {
				width: 100rpx;
				height: 100rpx;
			}
		}
	}
</style>
